package com.java1226;
//（1）创建类
public class Student {
    //(2)写成员变量
    String name;
    int age;
 // (3)生成构造方法
    public Student() {
    }
    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }
// (4)生成get,set;
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
    //(5)生成toString

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
    //(6) main 方法创建对象
    public static void main(String[] args) {
        Student s1 = new Student();
        s1.setName("wang");
        s1.setAge(10);
        System.out.println(s1);


        Student s2 = new Student("jack",18);
        System.out.println(s2);

        Student s3 = new Student("xu",20);
        System.out.println(s3);

        Student s4  = new Student("xgy",23);
        System.out.println(s4);
    }
}
